Skip to content

Port #[custom_mir(..)] to the new attribute system #145206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2025

Conversation

scrabsha
Copy link
Contributor

@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

let (dialect, span) = dialect?;

let dialect = match dialect.as_str() {
"analysis" => MirDialect::Analysis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can match directly on symbols here, so sym::analysis


let phase = match phase.as_str().to_ascii_lowercase().as_str() {
"initial" => MirPhase::Initial,
"post_cleanup" | "post-cleanup" | "postcleanup" => MirPhase::PostCleanup,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the original impl have 3 variants? This feels like something that should be specified and then changed to one of these 3


#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
#[derive(HashStable_Generic, PrintAttribute)]

Copy link
Contributor Author

@scrabsha scrabsha Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did i end up inserting a newline here?!

return;
};

let string_of_dialect = || match dialect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could implement a trait that allows these to be used in diagnostics directly. I forgot which, maybe IntoDiagnosticsValue? Something like that. It's from rustc_errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherent method name is usually a simple enough way to do that.

}
}
}

impl RuntimePhase {
pub fn parse(phase: Option<String>) -> Self {
pub fn parse(phase: Option<attrs::MirPhase>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method be inlined into its use sites now that it's so simple? Like the other *Phase::parse?

return;
};

let string_of_dialect = || match dialect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherent method name is usually a simple enough way to do that.

@jdonszelmann
Copy link
Contributor

@cjgillot yea I told sasha off-github the same yesterday. Let's just collapse all those alternate syntaxes into one and make them symbols. :)

@scrabsha
Copy link
Contributor Author

(i'm kinda busy trying to unbreak the tests, i'll go through all these discussions once i have something that works (i was convinced i ran the tests before opening the PR, but apparently no --'))

@scrabsha scrabsha force-pushed the push-uxovoqzrxnlx branch 3 times, most recently from 22677db to 4acaec2 Compare August 11, 2025 19:58
@scrabsha
Copy link
Contributor Author

@cjgillot @jdonszelmann I think I addressed everything you raised in this PR :)

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor

awesome, looks good! @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 12, 2025

📌 Commit e854013 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2025
Kobzol added a commit to Kobzol/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `@jdonszelmann`
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ``@jdonszelmann``
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 12, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ```@jdonszelmann```
@jhpratt
Copy link
Member

jhpratt commented Aug 12, 2025

@bors r-

#145317 (comment)

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 16, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 16, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `@jdonszelmann`
bors added a commit that referenced this pull request Aug 16, 2025
Rollup of 11 pull requests

Successful merges:

 - #139345 (Extend `QueryStability` to handle `IntoIterator` implementations)
 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 17, 2025
Rollup of 11 pull requests

Successful merges:

 - #139345 (Extend `QueryStability` to handle `IntoIterator` implementations)
 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ``@jdonszelmann``
bors added a commit that referenced this pull request Aug 17, 2025
Rollup of 10 pull requests

Successful merges:

 - #140794 (Add information about group a lint belongs to)
 - #144476 (rustdoc-search: search backend with partitioned suffix tree)
 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ```@jdonszelmann```
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ````@jdonszelmann````
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `````@jdonszelmann`````
bors added a commit that referenced this pull request Aug 17, 2025
Rollup of 10 pull requests

Successful merges:

 - #144476 (rustdoc-search: search backend with partitioned suffix tree)
 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)
 - #145489 (library: Migrate from `cfg_if` to `cfg_select`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 17, 2025
Rollup of 9 pull requests

Successful merges:

 - #144476 (rustdoc-search: search backend with partitioned suffix tree)
 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ``````@jdonszelmann``````
bors added a commit that referenced this pull request Aug 17, 2025
Rollup of 10 pull requests

Successful merges:

 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ```````@jdonszelmann```````
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ````````@jdonszelmann````````
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 17, 2025
…szelmann

Port `#[custom_mir(..)]` to the new attribute system

r? `````````@jdonszelmann`````````
bors added a commit that referenced this pull request Aug 18, 2025
Rollup of 10 pull requests

Successful merges:

 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 18, 2025
Rollup of 10 pull requests

Successful merges:

 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Aug 18, 2025
Rollup of 10 pull requests

Successful merges:

 - #144838 (Fix outdated doc comment)
 - #145206 (Port `#[custom_mir(..)]` to the new attribute system)
 - #145208 (Implement declarative (`macro_rules!`) derive macros (RFC 3698))
 - #145309 (Fix `-Zregparm` for LLVM builtins)
 - #145355 (Add codegen test for issue 122734)
 - #145420 (cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`)
 - #145451 (Add static glibc to the nix dev shell)
 - #145460 (Speedup `copy_src_dirs` in bootstrap)
 - #145476 (Fix typo in doc for library/std/src/fs.rs#set_permissions)
 - #145485 (Fix deprecation attributes on foreign statics)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d92e1fe into rust-lang:master Aug 18, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 18, 2025
rust-timer added a commit that referenced this pull request Aug 18, 2025
Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmann

Port `#[custom_mir(..)]` to the new attribute system

r? ``````````@jdonszelmann``````````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants